package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	// 设置URL和访问令牌
	accessToken := "80_uFF625ESLFb5ZzYCjL315tbtvQPJk4F20sWMyx461uM4AcUwiPfkp9Q8CIJVZjBFcyBbLaJcTtbgLBJ-1A53MsF-IJAFGQ_jXX3DzPhJtmLgO0cHMVkUfuJ0pm0VWYbABAJKM"
	url := fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/draft/batchget?access_token=%s", accessToken)

	// 创建请求体
	body := map[string]interface{}{
		"offset":     0,
		"count":      20,
		"no_content": 0,
	}

	// 将请求体编码为JSON格式
	jsonData, err := json.Marshal(body)
	if err != nil {
		fmt.Println("Error marshaling JSON:", err)
		return
	}

	// 创建HTTP请求
	req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
	if err != nil {
		fmt.Println("Error creating request:", err)
		return
	}

	// 设置请求头
	req.Header.Set("Content-Type", "application/json")

	// 发送请求
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error sending request:", err)
		return
	}
	defer resp.Body.Close()

	// 读取响应
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("Error reading response body:", err)
		return
	}

	// 输出响应
	fmt.Println("Response Status:", resp.Status)
	fmt.Println("Response Body:", string(respBody))
}
